package com.danielschon.triangularity.utility;

public class Vec {
	
	/**
	 * A class used to store a vector in the form of an ordered pair of floats
	 */
	
	public float x;
	public float y;
	
	public Vec(float a, float b){
		x = a;
		y = b;
	}
	
	public Vec(Vec v){
		x = v.x;
		y = v.y;
	}
	
	public void set(float a, float b){
		x = a;
		y = b;
	}
	
	public void set(Vec v){
		x = v.x;
		y = v.y;
	}
	
	public void add(float a, float b){
		x += a;
		y += b;
	}
	
	public void add(Vec v){
		x += v.x;
		y += v.y;
	}
	
	public void sub(float a, float b){
		x -= a;
		y -= b;
	}
	
	public void sub(Vec v){
		x -= v.x;
		y -= v.y;
	}
	
	public void mult(float a, float b){
		x *= a;
		y *= b;
	}
	
	public void mult(Vec v){
		x *= v.x;
		y *= v.y;
	}
	
	public void mult(float f){
		x *= f;
		y *= f;
	}
	
	public void div(float a, float b){
		x /= a;
		y /= b;
	}
	
	public void div(Vec v){
		x /= v.x;
		y /= v.y;
	}
	
	public void div(float f){
		x /= f;
		y /= f;
	}
	
	public Vec clone(){
		return new Vec(this.x, this.y);
	}
	
	public float getDistanceTo(Vec v){
		float dist = 0f;
		dist = (float) Math.sqrt(Math.pow(v.x - this.x, 2) + Math.pow(v.y - this.y, 2));
		return dist;
	}
	
}
